<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>节点列表</title>
    <link rel="shortcut icon" href="__STATIC__/admin/images/favicon.ico">
    <link href="__STATIC__/admin/assets/css/bootstrap.min.css" rel="stylesheet" />
    <link rel="stylesheet" href="__STATIC__/admin/assets/css/font-awesome.min.css" />
    <!--[if IE 7]>
    <link rel="stylesheet" href="__STATIC__/admin/assets/css/font-awesome-ie7.min.css" />
    <![endif]-->
    <link rel="stylesheet" href="__STATIC__/admin/assets/css/ace.min.css" />
    <link rel="stylesheet" href="__STATIC__/admin/assets/css/ace-rtl.min.css" />
    <link rel="stylesheet" href="__STATIC__/admin/assets/css/ace-skins.min.css" />
    <link rel="stylesheet" href="__STATIC__/admin/css/style.css" />
    <link rel="stylesheet" href="__STATIC__/admin/css/node.css" />
    <script src="__STATIC__/admin/js/jquery-1.9.1.min.js"></script>
    <script src="__STATIC__/admin/assets/js/bootstrap.min.js"></script>
    <script src="__STATIC__/admin/assets/layer/layer.js" type="text/javascript"></script>
</head>

<body>
<div class="crumbs">
    <ul>
        <li>
            <a href="javascript:;" class="active">节点管理</a>
        </li>
    </ul>
</div>
<div id="wrap">
    <a href="{:url('rbac/addrule')}">添加控制器</a>
    <div class="app">
        {foreach $rules as $rule}
        <dl>
            <dt>
                <strong>{$rule.title}</strong>
                [<a href="{:url('rbac/addrule',['id'=>$rule.id])}">添加方法</a>]
                [<a href="{:url('rbac/editerule',['id'=>$rule.id])}">修改</a>]
                [<a href="javascript:void(0);" class="del_rule" data-id="{$rule.id}" data-pp="controller">删除</a>]
            </dt>
            {foreach $rule.child as $item}
            <dd>
                <span>{$item.title}</span> [
                <a href="{:url('rbac/editerule',['id'=>$item.id])}">修改</a>] [
                <a href="javascript:void(0);" class="del_rule" data-id="{$item.id}" data-pp="action">删除</a>]
            </dd>
            {/foreach}
        </dl>
        {/foreach}
    </div>


</div>

</body>

</html>
<script>
    $('.del_rule').on('click',function () {
        var that=$(this);
        var id=$(this).data('id');
        var pp=$(this).data('pp');
        layer.confirm('真的要删除吗?',{icon:3,title:'删除提示'},function (index) {
            $.post('{:url("rbac/delrule")}',{id:id},function (res) {
                if(res.status==1){
                    if(pp=='controller'){
                        $(that).parent().parent().remove();
                    }else{
                        $(that).parent().remove();
                    }

                }
                layer.msg(res.msg);
            },'json')
        });
    })
</script>
